package com.gujia.concurrent.countdownlatch;

import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CountDownLatchDemo {

    public static void main(String[] args){
        Random r = new Random();

        ExecutorService service = Executors.newCachedThreadPool();
        CountDownLatch latch = new CountDownLatch(20);
        service.execute(new TestThread(latch));


        for (int i=0;i<20;i++){
            service.execute(new ModuleThread(latch,"模块"+i,r.nextInt(2000)+""));
        }

        service.shutdown();
    }
}
